// startDate: 计划开始时间； endDate：计划结束时间；dayLength：每隔几天，0-代表每天，1-代表日期间隔一天
function getDateStr(startDate, endDate, dayLength) {
    var str = startDate;
    for (var i = 0 ;; i++) {
        var getDate = getTargetDate(startDate, dayLength);
        startDate = getDate;
        if (getDate <= endDate) {
            str += ','+getDate;
        } else {
           break;
        }
    }
    return str;
}

// startDate: 开始时间；dayLength：每隔几天，0-代表获取每天，1-代表日期间隔一天
function getTargetDate(date,dayLength) {
    dayLength = dayLength + 1;
    var tempDate = new Date(date);
    tempDate.setDate(tempDate.getDate() + dayLength);
    var year = tempDate.getFullYear();
    var month = tempDate.getMonth() + 1 < 10 ? "0" + (tempDate.getMonth() + 1) : tempDate.getMonth() + 1;
    var day = tempDate.getDate() < 10 ? "0" + tempDate.getDate() : tempDate.getDate();
    return year + "-" + month + "-" + day;
}
//获取时间段内所有的月份
function getDateArry(start_time,end_time) {
    var d1 = start_time;
    var d2 = end_time;
    var dateArry = new Array();
    var s1 = d1.split("-");
    var s2 = d2.split("-");
    var mCount = 0;
    if (parseInt(s1[0]) < parseInt(s2[0])) {
        mCount = (parseInt(s2[0]) - parseInt(s1[0])) * 12 + parseInt(s2[1]) - parseInt(s1[1])+1;
    } else {
        mCount = parseInt(s2[1]) - parseInt(s1[1])+1;
    }
    if (mCount > 0) {
        var startM = parseInt(s1[1]);
        var startY = parseInt(s1[0]);
        for (var i = 0; i < mCount; i++) {
            if (startM < 12) {
                dateArry[i] = startY + "-" + (startM>9 ? startM : "0" + startM);
                startM += 1;
            } else {
                dateArry[i] = startY + "-" + (startM > 9 ? startM : "0" + startM);
                startM = 1;
                startY += 1;
            }
        }
    }
    return dateArry;
}
//获取所选月份的第一天
function getCurrentMonthFirst(yue){
    var startdate=new Date(yue);
    startdate.setDate(1);
    var year = startdate.getFullYear();
    var month = startdate.getMonth() + 1 < 10 ? "0" + (startdate.getMonth() + 1) : startdate.getMonth() + 1;
    var day = startdate.getDate() < 10 ? "0" + startdate.getDate() : startdate.getDate();
    return year + "-" + month + "-" + day;
};
//获取所选月份的最后一天
function getCurrentMonthLast(yue){
    var endDate = new Date(yue);
    var month=endDate.getMonth();
    var nextMonth=++month;
    var nextMonthFirstDay=new Date(endDate.getFullYear(),nextMonth,1);
    var oneDay=1000*60*60*24;
    var endtime = new Date(nextMonthFirstDay-oneDay);
    var year = endtime.getFullYear();
    var month = endtime.getMonth() + 1 < 10 ? "0" + (endtime.getMonth() + 1) : endtime.getMonth() + 1;
    var day = endtime.getDate() < 10 ? "0" + endtime.getDate() : endtime.getDate();
    return year + "-" + month + "-" + day;
};